package stream;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * @author Hongliang Zhu
 * @create 2021-08-01 13:40
 */
public class Demo2 {

    public static void main(String[] args) {

        List<Integer> list = Arrays.asList(7, 6, 9, 3, 8, 2, 1);

        list.stream().filter(x -> x > 6).forEach(System.out::println);

        Optional<Integer> first = list.stream().filter(x -> x > 6).findFirst();
        System.out.println(first.get());

        // 匹配任意（适用于并行流）
        Optional<Integer> findAny = list.parallelStream().filter(x -> x > 6).findAny();
        System.out.println(findAny.get());

        System.out.println("============================================================================");
        boolean b = list.stream().anyMatch(x -> x < 6);


    }
}
